package com.tjut.core;

import okhttp3.Cookie;
import okhttp3.CookieJar;
import okhttp3.HttpUrl;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;

public class DefaultCookieJar extends CookieManager{


    @Override
    public void saveFromResponse(@NotNull HttpUrl url, @NotNull List<Cookie> cookies) {
        this.cookies.addAll(cookies);
    }

    @NotNull
    @Override
    public List<Cookie> loadForRequest(@NotNull HttpUrl url) {
        List<Cookie> matchedCookies = new ArrayList<>();
        for (Cookie cookie : cookies) {
            if (cookie.matches(url)) {
                matchedCookies.add(cookie);
            }
        }
        return matchedCookies;
    }





}
